package example.hello_security.service;

import jakarta.annotation.Resource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class RedisStore {
    @Resource
    RedisTemplate<String, String> redisTemplate;


    /**
     * description 序列化后传输
     * @author zken
     * CreateDate 2024/10/26 23:12:25
     */
    public void set(String key, String value, long expire) {
        redisTemplate.opsForValue().set(key, value, expire, TimeUnit.MINUTES);
    }

    /**
     * description 序列化后获取
     * @author zken
     * CreateDate 2024/10/26 23:12:03
     */
    public String get(String key) {
        return redisTemplate.opsForValue().get(key);
    }

    /**
     * description 删除
     * @author zken
     * CreateDate 2024/10/26 23:14:29
     */
    public void remove(String key) {
        redisTemplate.delete(key);
    }
}




